import request from '../utils/request'

// 查询App列表
export const queryList = (params) => {
  return request({
    method: 'GET',
    url: 'app/rest/runtime/app-definitions',
    params: params
  })
}
// 查询App详情
export const queryDetail = (appDefId, versionId) => {
  let url = `modeler-app/rest/app-definitions/${appDefId}`
  if (versionId) {
    url += `/history/${versionId}`
  }
  return request({
    method: 'GET',
    url: url
  })
}

// 修改App
export const modifyOne = (id, data) => {
  return request({
    method: 'PUT',
    url: `modeler-app/rest/app-definitions/${id}`,
    data: data
  })
}

// 发布
export const publish = (id, data) => {
  return request({
    method: 'POST',
    url: `modeler-app/rest/app-definitions/${id}/publish`,
    data
  })
}

// 查询app对应的可调用流程
export const queryProcessForAppDef = () => {
  return request({
    method: 'GET',
    url: `modeler-app/rest/models-for-app-definition`
  })
}
